<?php
session_start();
//revised
include_once('server/config.php');
include_once('server/cmdVarControl.php');
include_once('server/emailer.php');
include_once('server/sqlControl.php');
include_once('server/specialFields.php');
include_once('dynCSS/global.php');
if (CM_LOGINTABLE != 'none')
{
	include_once('server/userControl.php');
	include_once('server/loginTickets.php');
	include_once('server/adminControl.php');
	include_once('server/cms.php');
	include_once('dynCSS/'.get('page').'.php');
	
	if (get('log') == 'create')
	{
		
		createNewAccount(post('fname'), post('lname'), post('userName'), post('password'), post('email'));
	}
	else if (get('log') == 'in')
	{
		adminlog('in');
	}
	else if (get('log') == 'out')
	{
		adminlog('out');
	}
}

$adminLinks = adminContent('
	<div id="adminContainer">
		<div id="adminLinks">
			<li><a href="'.INDEX.'admin'.EXT.'feat=users">User Accounts</a></li><li><a href="'.INDEX.'admin">Login Status</a></li><li><a href="'.INDEX.'home'.EXT.'log=out">LogOut</a></li>
		</div>
	</div>
	', '');
	
include_once('server/htmlPreProc.php');
	
//VARS


$addlHeadTags = '
<base href="'.BASEURL.'" />
';

$navigation ='home|home
orders|orders
accounts|accounts
items|items
control|app';

$navigationText = navigation(explode("\n", $navigation));
if (get('page') == 'null')
{
	echo redirectSiteNow(INDEX.'home');
}

$page = loadPage(explode("\n", $navigation));
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<title>Inventory Core System</title>
		<link href="css/global/reset.css" media="screen" type="text/css" rel="stylesheet" />
		<link href="css/global/960.css" media="screen" type="text/css" rel="stylesheet" />
		<link href="css/global/text.css" media="screen" type="text/css" rel="stylesheet" />
		<link href="css/global/layout.css" media="screen" type="text/css" rel="stylesheet" />
		<link href="css/global/typography.css" media="screen" type="text/css" rel="stylesheet" />
		<link href="css/global/editing.css" media="screen" type="text/css" rel="stylesheet" />
		<?php
		echo '<link href="css/'.get('page').'.css" media="screen" type="text/css" rel="stylesheet" />
';
		echo (isset($dynCSSOut) ? $dynCSSOut : '');
		$goCSS = (isset($dynCSS) ? $dynCSS : '');
		echo '
		<style type="text/css" media="all">
		<!--
		'.$dynGlobal.'
		'.$goCSS.'
		-->
		</style>
';
		?>
		
		
		<script src="js/mootools/core13.js" language="javascript"></script>
		<script src="js/mootools/more.js" language="javascript"></script>
		<script src="js/tinymce/jscripts/tiny_mce/tiny_mce.js" language="javascript"></script>
		<?php
		if (isset($dynJSGlobal))
		{
		echo (isset($dynJSOut) ? $dynJSOut : '');
			$goJS = '';
			if(isset($dynJS))
			{
				$goJS = $dynJS;
			}
			echo '
		<script type="text/javascript">
			<!--
			'.$dynJSGlobal.'
			'.$goJS.'
			-->
		</script>
		
';
		}
		?>
		<script src="js/cm/core.js" language="javascript"></script>
		<script src="js/lightbox/slimbox.js" language="javascript"></script>
		<script src="js/cm/tinymce.js" language="javascript"></script>
		<script src="js/mootools/scroll.js" language="javascript"></script>
	</head>
	<body>
		<div id="navContainer">
			<div id="navHeader">
				<div id="navProper">
					<?php
					if(get('page') != 'control')
					{
						echo adminContent('<ul class="nav">
						<li><a href="'.INDEX.'home">Inventory</a>
							<ul class="subnav">
								<li><a href="'.INDEX.'home" class="block">Main</a></li>
								<li><a href="'.INDEX.'orders'.EXT.'form=Sales" class="block">Check Out</a></li>
								<li><a href="'.INDEX.'orders'.EXT.'form=Purchase" class="block">Check In</a></li>
								<li><a href="#" class="block">Reports</a></li>
							</ul>
						</li>
						<li><a href="#">Directories</a>
							<ul class="subnav">
								<li><a href="#" class="block">Account Search</a></li>
								<li><a href="'.INDEX.'accounts'.EXT.'type=client" class="block">Client</a></li>
								<li><a href="'.INDEX.'accounts'.EXT.'type=supplier" class="block">Supplier</a></li>
							</ul>
						</li>
						<li><a href="'.INDEX.'items'.EXT.'view=items">Catalogue</a>
							<ul class="subnav">
								<li><a href="'.INDEX.'items'.EXT.'view=items" class="block">Items</a></li>
								<li><a href="'.INDEX.'items'.EXT.'view=categories" class="block">Categories</a></li>
								<li><a href="'.INDEX.'items'.EXT.'view=locations" class="block">Location</a></li>
							</ul>
						</li>
						<li><a href="#">Admin</a>
							<ul class="subnav">
								<li><a href="#" class="block">Users</a></li>
								<li><a href="#" class="block">Messages</a></li>
								<li><a href="http://www.clickmediaph.com" class="block" target="_blank">Support</a></li>
								<li><a href="'.INDEX.'home'.EXT.'log=out" class="block">Log Out</a></li>
							</ul>
						</li>
					</ul>','');
					}
					
					?>
				</div>
			</div>
		</div>
		<div id="dropShadow">
			</div>
		<div id="mainContainer">
			<div id="main960" class="container_12">
				<div id="pageContent" class="<?php echo get('page');?>">
					<?php echo $page;?>
				</div>
			</div>
		</div>
	</body>
</html>
